//
//  ZFCryptorTests.m
//  ZFCryptorTests
//
//  Created by zhaoliang on 10/08/2016.
//  Copyright (c) 2016 zhaoliang. All rights reserved.
//

#import <ZFCryptor/ZFCryptor.h>
#import <ZFCryptor/MD5Util.h>
#import <ZFCryptor/RSAUtil.h>

#import <CommonCrypto/CommonCrypto.h>

@import XCTest;

@interface Tests : XCTestCase

@end

@implementation Tests

- (void)setUp
{
    [super setUp];
    // Put setup code here. This method is called before the invocation of each test method in the class.
}

- (void)tearDown
{
    // Put teardown code here. This method is called after the invocation of each test method in the class.
    [super tearDown];
}

- (void)testExample
{
    XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__);
}

- (void)testDES3
{
    NSString *key = @"abcdefg";
    NSString *str = @"helle world  你好世界 ？、/#@￥%……&（）！~";
    
    NSString *str3 = [ZFCryptor cryptStrByBase64:str tripleKey:key algorithm:ZFCryptAlgorithm3DES operation:ZFCryptEncrypt];
    NSString *str4 = [ZFCryptor cryptStrByBase64:str3 tripleKey:key algorithm:ZFCryptAlgorithm3DES operation:ZFCryptDecrypt];
    
    NSLog(@"DES3\n%@ \n %@", str3,str4);
}

- (void)testDES
{
    NSString *str = @"helle world  你好世界 ？、/#@￥%……&（）！~";
    NSString *key = @"abcdefg";
    
    NSString *str3 = [ZFCryptor cryptStrByBase64:str tripleKey:key algorithm:ZFCryptAlgorithmDES operation:ZFCryptEncrypt];
    NSString *str4 = [ZFCryptor cryptStrByBase64:str3 tripleKey:key algorithm:ZFCryptAlgorithmDES operation:ZFCryptDecrypt];
    
    NSLog(@"DES\n%@ \n %@", str3,str4);
}

- (void)testAES
{
    NSString *str = @"helle world  你好世界 ？、/#@￥%……&（）！~";
    NSString *key = @"abcdefg";
    
    NSString *str3 = [ZFCryptor cryptStrByBase64:str tripleKey:key algorithm:ZFCryptAlgorithmAES256 operation:ZFCryptEncrypt];
    NSString *str4 = [ZFCryptor cryptStrByBase64:str3 tripleKey:key algorithm:ZFCryptAlgorithmAES256 operation:ZFCryptDecrypt];
    NSLog(@"\n%@ \n %@", str3,str4);
}

- (void)testMD5
{
    NSString *str = @"helle world  你好世界 ？、/#@￥%……&（）！~";
    
    NSString *str1 = [MD5Util md5:str];
    NSLog(@"MD5 \n%@", str1);
}

- (void)testRSA
{
    NSString *str = @"helle world  你好世界 ？、/#@￥%……&（）！~";
    
    NSString *str1 = [RSAUtil getPublicKey];
    NSLog(@"RSA \n%@", str1);
}

@end

